package org.lsy.service;

import org.apache.dubbo.config.annotation.Service;
import org.apache.dubbo.rpc.RpcContext;

import java.util.Random;
import java.util.concurrent.TimeUnit;

/**
 * @author liusy95
 * @version 1.0
 * @date 2020/6/30
 */
@Service
public class DemoServiceImpl implements DemoService {

    @Override
    public boolean methodA(){
        return doHandle();
    }

    @Override
    public boolean methodB() {
        return doHandle();
    }

    @Override
    public boolean methodC() {
        return doHandle();
    }

    private boolean doHandle() {
        Random random = new Random();
        try {
            TimeUnit.MILLISECONDS.sleep(random.nextInt(100));
            System.out.println(Thread.currentThread().getId());
            return true;
        } catch (InterruptedException e) {
            System.err.println(e.getMessage());
            return false;
        }
    }
}
